# coding: utf8
from .. import db
import json
import datetime


class Course(db.Model):
    __tablename__ = 'course'
    id = db.Column('id', db.Integer, primary_key=True)
    title = db.Column(db.String(255))
    desc = db.Column(db.String(255))
    status = db.Column(db.Integer)
    images = db.relationship('CourseImage', lazy="select")


class CourseImage(db.Model):
    __tablename__ = 'course_image'
    id = db.Column('id', db.Integer, primary_key=True)
    url = db.Column(db.TEXT)
    course_id = db.Column(db.Integer, db.ForeignKey('course.id'))
    goods = db.relationship('Good', lazy="select")

class Good(db.Model):
    __tablename__ = 'good'
    id = db.Column('id', db.Integer, primary_key=True)
    image_id = db.Column(db.Integer, db.ForeignKey('course_image.id'))
    name = db.Column(db.String(255))

